﻿//通用模板JS
$(function(){
    var fn = ABUS.Fn;
    $("#closeModal").on("touchend",function(){
        fn.closeModal();
    });
    $("#openAlertModalSuccess").on("touchend",function(){
        fn.alert({
            type:"success",
            title:"已支付成功"
        })
    });
    $("#openAlertModalError").on("touchend",function(){
        fn.alert({
            type:"error",
            title:"金额不足支付失败",
            mask:false
        })
    });
    $("#openPaymentModal").on("touchend",function(){
        fn.payment({
            onSubmit:function(){
                console.log('onsubmit');
                fn.closeModal();
            },
            onCancel:function(){
                console.log('oncancel');
                fn.closeModal();
            }
        })
    });
    $("#openInfoModal").on("touchend",function(){
        fn.info({
        })
    });
    $("#openSelectModal").on("touchend",function(){
        fn.scrollSelect({
//        theme: undefined,
            id:'#openSelectModal',
            headerText:'<div class="_title">选择租车时长</div>',
            wheels: [
                [{
                    label: '-',
                    data: ["单程","往返","包天"]
                }]
            ],
            rows:3,
            width:200
        })
    });
    $("#openTimeModal").on("touchend",function(){
        fn.scrollSelect({
//        theme: undefined,
            id:'#openTimeModal',
            headerText:'<div class="_title">选择出发时间</div>',
            wheels: [
                [{
                    label: '日期',
                    data: [{
                        value:"12月1日",
                        display:"12月1日（星期六）"
                    },{
                        value:"12-2",
                        display:"12月2日（星期六）"
                    }]
                }, {
                    label: '时',
                    data: [{
                        value:"0时",
                        display:"0"
                    },{
                        value:"1时",
                        display:"1"
                    }]
                }, {
                    label: '分',
                    data:  [{
                        value:"0时",
                        display:"0"
                    },{
                        value:"1时",
                        display:"1"
                    }]
                }]
            ],
            rows:8
        })
    });
    $("#openTravelInfoModal").on("touchend",function(){
        fn.travelInfo({
        })
    });

    //在页面上填值
    var $el = $("#commonDemo");
    fn.get({
        url:'./simdata/common.json',
        data:{
            param:1
        },
        type:"POST",
        success:function(data){
            if(data.result.status == 1){
                data = data.data;
                $el.find(".name").text(data.name);
                $el.find(".age").text(data.age);
            }else{
                fn.alert({
                    type:"error",
                    title:data.result.message
                })
            }
        }
    });

    //跳转到第二个页面并返回数据(有回调)
    $('#gotoSecondPage').on('touchend',function(){
        fn.page_goto({
            url:"./secondpage.html",
            data:{
                msg:"来自common的参数"
            }
        },function (data) {
            alert(data)
        })
    })

    //跳转到第二个页面并返回数据（无回调）
    $('#openUrlSecondPage').on('touchend',function(){
        fn.page_goto({
            url:"./secondpage.html",
            data:{
                msg:"来自common的参数"
            }
        })
    })
});